﻿CREATE TABLE [dbo].[Accounts_User] (
    [User_GUID]               UNIQUEIDENTIFIER NOT NULL,
    [username]                VARCHAR (255)    NOT NULL,
    [passwordencrypt]         VARCHAR (255)    NOT NULL,
    [password_lastchanged]    DATETIME         NULL,
    [password_failedattempts] INT              CONSTRAINT [DF_Accounts_User_password_failedattempts] DEFAULT ((0)) NOT NULL,
    [account_disabled]        BIT              CONSTRAINT [DF_Accounts_User_account_disabled] DEFAULT ((0)) NOT NULL,
    [account_resetguid]       UNIQUEIDENTIFIER NULL,
    [account_resetdate]       DATETIME         NULL,
    [account_lastlogindate]   DATETIME         NULL,
    CONSTRAINT [PK_Accounts_User] PRIMARY KEY CLUSTERED ([User_GUID] ASC),
    CONSTRAINT [PASSWORDENCRYPT_LENGTH_CK] CHECK (len([passwordencrypt])>(0)),
    CONSTRAINT [USERNAME_LENGTH_CK] CHECK (len([username])>(0)),
    UNIQUE NONCLUSTERED ([username] ASC)
);


GO
CREATE NONCLUSTERED INDEX [Accounts_User_username_pwd_Index]
    ON [dbo].[Accounts_User]([username] ASC, [passwordencrypt] ASC);

